//
//  ZHClinicPatientViewController.m
//  Doctor
//
//  Created by liuzhishan on 15/12/16.
//  Copyright © 2015年 shanshan. All rights reserved.
//

#import "ZHClinicPatientViewController.h"
#import "ZHLineChartView.h"
#import "ZHShowSpline.h"


@interface ZHClinicPatientViewController ()

@property (nonatomic,strong) ZHLineChartView *lineView;

@end

@implementation ZHClinicPatientViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    self.lableTitle.text = @"诊所患者数";
    
    
    ZHLineChartView *lineChartView = [[ZHLineChartView alloc]init];
    [lineChartView setMyFramewithX:40 andY:380 andWidth:915 andHeight:300];
    
    [self.view addSubview:lineChartView];
    self.lineView = lineChartView;

    
    ZHShowSpline *show1 = [[ZHShowSpline alloc]init];
    [show1  setMyFramewithX:430 andY:300 andWidth:85 andHeight:70];
    show1.imageViewUp.image = [UIImage imageNamed:@"orange"];
    show1.lableDown.text = @"复诊人数";
    [self.view addSubview:show1];
    
    ZHShowSpline *show2 = [[ZHShowSpline alloc]init];
    [show2  setMyFramewithX:600 andY:300 andWidth:85 andHeight:70];
    show2.imageViewUp.image = [UIImage imageNamed:@"green"];
    show2.lableDown.text = @"初诊人数";
    
    [self.view addSubview:show2];
    
    [self getDataWithAFN];
    
    __weak ZHClinicPatientViewController *weakSelf =self;
    [self.timePickerView setMyBlock:^(id responseObject) {
        
        
        NSMutableArray *array = [ZHClinicModelTool getDateArrayWithResponseObject:responseObject];
        
        [ZHSaveClickDate shareData];
        [ZHSaveClickDate getClassValueWithArray:array andSingleName:@"income"];
        
        weakSelf.lineView.dataArray = array;
        
        
        
    }];

    
    
    
}


-(void)getDataWithAFN
{
    [AFNData getAFNDataWithUrl:self.clinicURL success:^(id responseObject) {
        
        
        NSMutableArray *array = [ZHClinicModelTool getDateArrayWithResponseObject:responseObject];
        
        [ZHSaveClickDate shareData];
        [ZHSaveClickDate getClassValueWithArray:array andSingleName:@"patient"];
        
        self.lineView.dataArray = array;
        
        
    } failure:^(NSError *error) {
        
        
    }];
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
